package cn.bugstack.config;



import cn.bugstack.infrastructure.gateway.IWeixinApiService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

/**
 * @author 丨一
 * @version 1.0
 * @title Retrofig2Config
 * @description: 实例化Retrofit2类
 * @date 2024/11/10 18:22
 */

@Configuration
public class Retrofit2Config {

    private static final String BASE_URL = "https://api.weixin.qq.com";

    /**
     * 实例化Retrofit2类
     * @return Retrofit2实例化对象
     */
    @Bean
    public Retrofit retrofit() {
        return new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(JacksonConverterFactory.create()).build();
    }

    /**
     * 代理接口的实现类
     * @param retrofit
     * @return
     */
    @Bean
    public IWeixinApiService weixinApiService(Retrofit retrofit) {
        return retrofit.create(IWeixinApiService.class);
    }
}
